package cn.kgm.makeGod.condition;

import cn.kgm.makeGod.Character;
import cn.kgm.makeGod.Relationship;
import cn.kgm.makeGod.RelationshipType;
import lombok.Data;

/**
 * @Version 1.8
 * @Author: Kappi
 * @Date: 2025-9-11 11:27
 * @Description: cn.kgm.makeGod.condition.RelationshipCondition
 */
@Data
public class RelationshipCondition implements Condition {

    private RelationshipType relationType;
    private Integer minValue;
    private Integer maxValue;

    public RelationshipCondition() {
    }

    public RelationshipCondition(RelationshipType relationType, Integer minValue, Integer maxValue) {
        this.relationType = relationType;
        this.minValue = minValue;
        this.maxValue = maxValue;
    }

    @Override
    public boolean check(Character actor, Character target, WorldState world) {
        Relationship rel = actor.getRelationshipTo(target.getId());
        if (rel == null) return false;

        if (relationType != null && rel.getType() != relationType) return false;
        if (minValue != null && rel.getValue() < minValue) return false;
        if (maxValue != null && rel.getValue() > maxValue) return false;

        return true;
    }

}
